/*
 * Created: Author: Aléx Carvalho / Date: Jan 23, 2015
 * 
 * Changed: $Author: ac280593@gmail.com $ / $Date: 2015-06-12 03:38:01 +0000 (Fri, 12 Jun 2015) $
 */
package com.cpm.entities;

import com.cpm.entities.converters.LocalDatePersistenceConverter;
import com.cpm.entities.id.IntegerId;
import com.cpm.entities.types.Family;
import com.cpm.wrapper.Limit;
import com.cpm.wrapper.Performance;
import java.time.LocalDate;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;

@Entity
public class StrategicPlan extends IntegerId implements Identity<StrategicPlan> {

    @AttributeOverride(name = "limit", column = @Column(name = "limitLow"))
    private Limit limitLow;

    @AttributeOverride(name = "limit", column = @Column(name = "limitMid"))
    private Limit limitMid;

    @AttributeOverride(name = "limit", column = @Column(name = "limitHigh"))
    private Limit limitHigh;

    private Performance performance;

    @ManyToOne(optional = false)
    private User responsible;
    
    @Column(length = 200, nullable = false)
    private String name;

    @Column(nullable = false, length = 5)
    @Convert(converter = LocalDatePersistenceConverter.class)
    private LocalDate dtStart;

    @Column(nullable = false, length = 5)
    @Convert(converter = LocalDatePersistenceConverter.class)
    private LocalDate dtEnd;

    public StrategicPlan() {
    }

    public StrategicPlan(User responsible, Limit limitLow, Limit limitMid, Limit limitHigh, Performance performance, String name, LocalDate dtStart, LocalDate dtEnd) {
        this.responsible = responsible;
        this.limitLow = limitLow;
        this.limitMid = limitMid;
        this.limitHigh = limitHigh;
        this.performance = performance;
        this.name = name;
        this.dtStart = dtStart;
        this.dtEnd = dtEnd;
    }

    public String getName() {
        return name;
    }
    
    public void setPerformance(Performance performance) {
        this.performance = performance;
    }

    public Performance getPerformance() {
        return performance;
    }
    
    public Limit getLimitHigh() { return limitHigh; }

    public Limit getLimitMid() { return limitMid; }
    
    public Limit getLimitLow() { return limitLow; }

    @Override
    public StrategicPlan clone() {
        return null;
    }
    
    @Override
    public Family getFamily() { return Family.STRATEGIC_PLAN; }

    @Override
    public String toString() { return name; }
}
